#include "instructionwidget.h"
#include "qboxlayout.h"

instructionwidget::instructionwidget(QWidget *parent) : QWidget(parent)
{
    //设置背景、贴图
    QPixmap p=QPixmap("3.png");
    interface.setPixmap(QPixmap("3.png"));
    picture[0].setPixmap(QPixmap("Tom.png"));
    picture[1].setPixmap(QPixmap("Jerry.png"));
    int x=p.width(),y=p.height();

    //编辑要说明的内容
    instruction[0].setText("Tom，一只蓝灰色家猫,穿上帘子意外学会飞行。");
    instruction[0].setParent(&interface);
    instruction[1].setText("Jerry，一只棕毛花枝鼠，坐在土块上被Tom击飞。");
    instruction[1].setParent(&interface);
    instruction[2].setText("通过W,S,A,D键进行上下左右移动，Q：向上瞬移，Z：向下瞬移");
    instruction[2].setParent(&interface);

    //标签位置
    instruction[0].setFixedSize(100,100);
    instruction[1].setFixedSize(100,100);
    instruction[2].setFixedSize(100,100);

    //标签样式
    //换行、背景颜色、字体、字号、字体颜色
    instruction[0].setAlignment(Qt::AlignLeft | Qt::AlignTop);
    instruction[1].setAlignment(Qt::AlignLeft | Qt::AlignTop);
    instruction[2].setAlignment(Qt::AlignLeft | Qt::AlignTop);

    instruction[0].setWordWrap(true);
    instruction[1].setWordWrap(true);
    instruction[2].setWordWrap(true);

    instruction[0].setStyleSheet("background-color:white; border: black;font-family: 楷体; font-size: 15px; color: #4148FF;");
    instruction[1].setStyleSheet("background-color:white; border: black;font-family: 楷体; font-size: 15px; color: #4148FF;");
    instruction[2].setStyleSheet("background-color:transparent; border: black;font-family: 楷体; font-size: 15px; color: #4148FF;");

    //设置返回按钮
    back.setText("返回");
    back.setParent(&interface);

    //按钮样式
    back.setFixedSize(80,30);
    back.setStyleSheet("background-color: none; border: none;font-family: 楷体; font-size: 30px; color: #F33333;");
    back.move((x-100), y*0.75);

    //信号与槽返回主界面
    connect(&back, &QAbstractButton::clicked, this, &instructionwidget::close);

    //设置布局
    QVBoxLayout mainbox,finalbox;
    mainbox.addWidget(&interface);

    QHBoxLayout twopics,twoins,box;

    instruction[2].move(300,50);

    twopics.addWidget(&picture[0]);
    twopics.addWidget(&picture[1]);
    twoins.addWidget(&instruction[0]);
    twoins.addWidget(&instruction[1]);

    finalbox.addLayout(&twopics);
    finalbox.addLayout(&twoins);

    box.addLayout(&finalbox);
    box.addWidget(&back,50,Qt::AlignBottom);

    interface.setLayout(&box);

    this->setLayout(&mainbox);

}

instructionwidget::~instructionwidget()
{
}
